import Vue from 'vue';
import Stage from './views/Stage.vue';
import StageSobot from './views/StageSobot.vue';
import StageTianRun from './views/StageTianRun.vue';
import http from '@src/util/http';
import mtracker from '@src/util/mtracker';
/* service */
import CallCenterService from '@service/CallCenterService';
import { setTabTitle } from '@src/util/tabTitle';

const isCallCenterZhiChi = CallCenterService.getIsCallCenterZhiChi();

const isCallCenterTianRun = CallCenterService.getIsCallCenterTianRun()

Vue.prototype.$http = http;
Vue.prototype.$eventBus = new Vue();

mtracker();
// 处理注入的参数
let initData = {};
try {
  initData = JSON.parse(window._init || '{}') || {};
} catch (error) {
  console.error(error);
  console.error('no init data')
}

// const CallCenterComp = Vue.extend(isCallCenterZhiChi ? StageSobot : Stage);
// const app = new Vue({
//   provide: {
//     initData: Object.freeze(initData)
//   },
//   render: h => h(CallCenterComp),
//   el: '#app'
// });
let CallCenterComp = Stage
if( isCallCenterZhiChi ){
  CallCenterComp = StageSobot
}else if(isCallCenterTianRun){
  CallCenterComp = StageTianRun
}
let app = {
  provide: {
    initData: Object.freeze(initData)
  },
  render: h => h(CallCenterComp)
}

setTabTitle()

export default app;